use salvo::{Depot, handler, Request};

use crate::{
    config::api_config::ApiResult, entity::sys_user::SysUser, service::user_service::UserService,
};


use crate::entity::Page;

#[handler]
#[tracing::instrument]
pub async fn user_page(request: &mut Request, depot: &mut Depot) -> ApiResult<Page<SysUser>> {
    let result = UserService::page(request, depot).await;
    ApiResult::from(result)
}

#[handler]
#[tracing::instrument]
pub async fn add_user(request: &mut Request, depot: &mut Depot) -> ApiResult<()> {
    let result = UserService::add_user(request, depot).await;
    ApiResult::from(result)
}

#[handler]
#[tracing::instrument]
pub async fn del_user(request: &mut Request, depot: &mut Depot) -> ApiResult<()> {
    ApiResult::from(UserService::del_user(request, depot).await)
}
